package model

import (
	"video-management-system/userrpc/userrpc"

	"gorm.io/gorm"
)

type TopicInfo struct {
	gorm.Model
	TopicName  string `gorm:"type:varchar(30)"`
	TopicIntro string `gorm:"type:text"`
	HotLevel   string `gorm:"type:enum('0','1');default:'0';not null"`
}

func (i *TopicInfo) VideoTopicShow(db *gorm.DB, tid int64) userrpc.VideoTopicShowResponse {
	var list userrpc.VideoTopicShowResponse
	db.Debug().Model(&TopicInfo{}).Select("topic_infos.*").
		Joins("left join video_infos ON  topic_infos.id = video_infos.tid").
		Where("topic_infos.id=?", tid).First(&list)
	return list
}
